#pragma once
#include "Meter.h"
#include "YeWei.h"
#include "SwitchCtrl.h"
#include "DA.h"
#include "ComDefine.h"
#include "YaLi.h"
#include "ianalogdisplayx.h"
#include "Ctrl.h"
#include "ilabelx.h"
#include "ipipex.h"
#include "vector"
#include "ivalvex.h"
#include "imotorx.h"
UINT DelayOpenThread(LPVOID pParam);
class CTankBase
{
public:
	CTankBase(void);
	~CTankBase(void);
	void Create(
		int index, 
		int id, 
		HWND hwnd,
		CSwitchCtrl *switch_port = NULL,
		CLocalModbus *temp_port = NULL,
		CLocalModbus *yewei_port = NULL, 
		CLocalModbus *yali_port = NULL,
		HANDLE da_handle = INVALID_HANDLE_VALUE);
	void SetIndex(int index);
	int	GetIndex();
	void SetID(int id);
	void SetHWND(HWND hwnd);
	float GetCurTemp();
	void SetTarTemp(float fTemp);
	float GetTarTemp();
	float GetTarYeWei();
	float GetTarYaLi();
	float GetCurYeWei();
	float GetCurYaLi();
	void SetTarYaLi(float fYaLi);
	void SetTarYeWei(float fYeWei);
	BOOL IsOpen();
	void DelayOpenSwitch(int index);
	void DelayCloseSwitch(int index);
	void OpenSwitch(int index);
	void CloseSwitch(int index);
	int GetDelayOpenSwitch();
	int GetDelayCloseSwitch();
	void OpenDASwitch(int daChannel, int pos);
	void SetMyTimer(UINT_PTR nIDEvent, UINT eClapse);
	void OpenTank();
	void ClsoeTank();
	STATE GetCurState();
	void SetCurState(STATE state);
	void WriteTarYaLi();
	void WriteLoYaLi();
	void WriteTarTemp();
	void WriteLoTemp();
	void WriteTarYeWei();
	void WriteLoYeWei();
	void SetLabelText(const wchar_t *str);
	void OpenShangLiaoSwitch();
	void OpenXieLiaoSwitch();
	void CloseShangLiaoSwitch();
	void CloseXieLiaoSwitch();
	float YeWei();
	float YaLi();
	float Temp();
	HWND GetHwnd();
	void SetStop();
	//STATE GoNextStep();
	//virtual void TongGuanDao() = 0;
	//virtual void XieLiao() = 0;
	//virtual void ShangLiao() = 0;
	//virtual void GoNextStep() = 0;
	CiLabelX *pLabel;
	CiValveX *pShangLiaoSwitch;
	CiValveX *pXieLiaoSwitch;
	std::vector<CiPipeX*>vPipesShangLiao;
	std::vector<CiPipeX*>vPipesXieLiao;
protected:
	int _index;
	int _ID;
	int _iTGDTime;
	int _iXieLiaoTime;
	float _fCurTemp;
	float _fCurYeWei;
	float _fTarTemp;
	float _fTarYeWei;
	float _fCurYaLi;
	float _fTarYaLi;
	float _fLastTemp;
	CMeter _meter;
	CYeWei _yewei;
	CYaLi _yali;
	CSwitchCtrl *_pSwitchCtrl;
	CDA _da;
	int _iSwitchToOpen;
	int _iSwitchToClose;
	BOOL _bIsOpen;
	HWND _hwnd;
	CCtrl _ctrl;
	
};
